package com.sise.rsc.service;

import com.sise.rsc.entity.Courier;
import com.sise.rsc.entity.WorkingArea;
import com.sise.rsc.repository.CourierRepository;
import com.sise.rsc.repository.WorkingAreaRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional
public class AdminService {

    @Resource
    private WorkingAreaRepository workingAreaRepository;
    @Resource
    private CourierRepository courierRepository;

    public WorkingArea findWorkingAreaById(Integer id){
        return  workingAreaRepository.findWorkingAreaById(id);
    }

    public WorkingArea findWorkingAreaByAddressName(String addressName){
        return workingAreaRepository.findWorkingAreaByAddressName(addressName);
    }
    //查询所有工作区域
    public List<WorkingArea> findAllWorkingArea(){
        return workingAreaRepository.findAllWorkingAreas();
    }


    public void addWorkingAres(WorkingArea workingArea){
        workingAreaRepository.save(workingArea);
    }
    //添加快递员
    public void addCourier(Courier courier){
        courierRepository.save(courier);
    }
    //查询所有快递员
    public List<Courier> listCourier(){
        return  courierRepository.findAllCourier();
    }
    //查询所有快递员BycId
    public Courier listCourierBycId(int cid){
        return  courierRepository.findCourierById(cid);
    }


    public Courier findCourierByNo(String  no){
        return courierRepository.findCourierByNo(no);
    }


}
